#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<stdio.h>
using namespace std;
#include<iostream>
int main()
{
	int a[25] = { 0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9 };
	int resultcount = 0;
	do 
	{
		int A = a[0] * 100 + a[1] * 10 + a[2];
		int B = a[3] * 100 + a[4] * 10 + a[5];
		int C = a[6] * 100 + a[7] * 10 + a[8];
		int D = a[9] * 100 + a[10] * 10 + a[11];
		int E = a[12] * 100 + a[13] * 10 + a[14];
		int F = a[15] * 10000 + a[16] * 1000 + a[17] * 100 + a[18] * 10 + a[19];
		if ((A * B == F) && (C + D * 10 + E * 100 == F) && (a[5] * A == C) && (a[4] * A == D) && (a[3] * A == E) && (F <= 99999))
			resultcount++;
	} while (next_permutation(a, a + 20));
	cout << resultcount;
	return 0;
}




